package com.wangzh.concurrent.lock.function;

import java.util.Arrays;
import java.util.Comparator;
import java.util.List;

public class StreamDemo {
    public static void main(String[] args) {
//        List<String> list = Arrays.asList("a", "b");
//        String a = list.stream().filter(e -> e.equals("a")).toString();


        User a1 = new User("a", 3);
        User a2 = new User("b", 7);
        User a3 = new User("f", 1);
        User a4 = new User("c", 3);
        User a5 = new User("h", 3);

        List<User> list = Arrays.asList(a1, a2, a3, a4, a5);
        list.stream()
                .map(e -> e.getName())
                .sorted(Comparator.reverseOrder())
                .forEach(e -> {
                    System.out.println(e);
                });


    }
}

class User {
    private String name;
    private Integer age;

    public User(String name, Integer age) {
        this.name = name;
        this.age = age;
    }

    public User() {
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    @Override
    public String toString() {
        return "User{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }
}
